const {
  override,
  fixBabelImports,
  addLessLoader
} = require('customize-cra');

const config = (config, env) => {
  const publicPath = env === 'production' ?
    'https://cdn.hterobot.com/vue/' : '/'
  config.output.publicPath = publicPath
  return config
}

module.exports = override(
  config,
  // 按需加载 antd
  fixBabelImports('import', {
    libraryName: 'antd',
    libraryDirectory: 'es',
    style: true,
  }),
  // 添加加载 less 的 javascriptEnabled 和 antd 的主题配置。
  addLessLoader({
    javascriptEnabled: true,
  }),
);